Test Series - java script

Test Number 21/92

Q: Rhino is originated by _______
A. Microsoft
B. Mozilla
C. Apple
D. Chrome
Solution: Rhino is a JavaScript engine written fully in Java and managed by the Mozilla Foundation as open source software. Rhino is free software from Mozilla. You can download a copy from http://www.mozilla.org/rhino/.
Q: Which of the following are global functions that are not part of core JavaScript?
A. spawn(f);
B. trim();
C. exult();
D. eval()
Solution: The spawn(f) runs f() or loads and executes file f in a new thread.
Q: Which of the following reads the textual contents of a URL and returns as a string?
A. spawn(f);
B. load(filename,…);
C. readFile(file);
D. readUrl(url);
Solution: Rhino defines a handful of important global functions that are not part of core JavaScript in which readUrl(url) reads the textual contents of a URL and return as a string.
Q: Which Rhino command quits Rhino environment?
A. terminate()
B. exit()
C. quit()
D. close()
Solution: quit() is a predefined command in rhino. The quit() command makes Rhino exit.
Q: Which is a useful way to try out small and simple Rhino programs and one-liners?
A. Starting an interactive shell
B. Starting a one to one shell
C. Creating a thread to do simple programs
D. Starting a multiple shell
Solution: Rhino is distributed as a JAR archive. Start it with a command line like this :
java -jar rhino1_7R2/js.jar program.js
If you omit program.js, Rhino starts an interactive shell, which is useful for trying out simple programs and one-liners.
Q: Which is a more formal way of importing packages and classes as JavaScript objects?
A. import(java.util.*);
B. importClass(java.util.*);
C. import.Class(java.util.*);
D. Class.import(java.util.*);
Solution: Because packages and classes are represented as JavaScript objects, you can assign them to variables to give them shorter names. But you can also more formally import them, if you want to:
importClass(java.util.HashMap); // Same as : var HashMap = java.util.HashMap
Q: What does Rhino do when the getter and setter methods exist?
A. It becomes JavaScript properties
B. Java classes are used to avoid them
C. Java classes & JavaScript properties
D. It act as javascript function
Solution: Rhino allows JavaScript code to query and set the static fields of Java classes and the instance fields of Java objects. Java classes often avoid defining public fields in favor of getter and setter methods. When getter and setter methods exist, Rhino exposes them as JavaScript properties.
Q: The JavaScript classes can be instantiated using _____ operator.
A. create
B. new
C. instantiate
D. create.new
Solution: New is a keyword in JavaScript which is used to define new models. New operator is used to create new instance of the class.
Q: The new Java arrays can be created into JavaScript programs using which of the following classes?
A. java.Array
B. java.lang.*
C. java.lang.Array
D. java.lang.reflect.Array
Solution: There is no natural JavaScript syntax that Rhino can extend to allow JavaScript programs to create new Java arrays, so you have to do that using the java.lang.reflect.Array class.
Q: What will be the output of the following JavaScript code?

A. 6
B. 7
C. 49
D. Error
Solution: Math.sqrt function returns the square root of the argument passed to it. It is found in the math library of Javascript.

You Have Score    /10